package com.bone.order.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bone.common.BaseIbatisDAO;
import com.bone.order.po.OrdOrder;
import com.bone.order.po.OrdOrderProd;
import com.bone.page.Page;


/**
 * DAO.
 * @author liwenzhan
 *
 */
public class OrdOrderProdDAO extends BaseIbatisDAO {

	
	
	/**
	 * 取符合查询条件的数据.
	 * @param parameter
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public Page<OrdOrderProd> queryOrderPageByParam(Map<String, Object> para,Page page){     
		Long totalResultSize = (Long) getSqlMapClientTemplate().queryForObject("ORD_ORDER_PROD.queryCountByParam", para);
		page.setTotalResultSize(totalResultSize);				
		para.put("startRows", page.getStartRows());				
		para.put("endRows", page.getEndRows());
		para.put("_order", "prod_id");
		page.setItems(getSqlMapClientTemplate().queryForList("ORD_ORDER_PROD.queryPageByParam", para));
		return page;
	}
	
	/**
	 * 
	 * @param orderId
	 * @return
	 */
	public OrdOrderProd queryOrdOrderProdById(Long prodId){     
		 return (OrdOrderProd)this.getSqlMapClientTemplate().queryForObject("ORD_ORDER_PROD.queryOrdOrderProdById", prodId);
	}
	
	/**
	 * 
	 * @param orderNo
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<OrdOrderProd> queryOrdOrderProdListByOrderNo(Long orderNo){ 
		return  this.getSqlMapClientTemplate().queryForList("ORD_ORDER_PROD.queryOrdOrderProdListByOrderNo", orderNo);
	}
	
	/**
	 * 
	 * @param orderId
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<OrdOrderProd> queryOrdOrderProdListByOrderId(Long orderId){   
		return  this.getSqlMapClientTemplate().queryForList("ORD_ORDER_PROD.queryOrdOrderProdListByOrderId", orderId);
	}
	
	
	
	/**
	 * .
	 * @param objectId
	 * @return
	 */
	public OrdOrder queryOrdOrderProdListByParam(final OrdOrderProd ordOrderProd){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("prodId", ordOrderProd.getProdId());
		map.put("orderNo", ordOrderProd.getOrderNo());
		map.put("orderId", ordOrderProd.getOrderId());
		map.put("productId", ordOrderProd.getProductId());
		map.put("productName", ordOrderProd.getProductName());
		return  (OrdOrder) super.getSqlMapClientTemplate().queryForObject("ORD_ORDER_PROD.queryOrdOrderProdListByParam", map);
	}
	
	

}
